<template>
	<view class="container">
		<!-- 头部标题 -->
		<view class="cu-bar bg-white">
			<view class="action sub-title">
				<text class="text-xl text-bold text-green">我的课堂</text>
				<text class="bg-green" style="width: 66vw;"></text>
				<text @click.native="toTClassDescPage()"  class="lg  cuIcon-qr_code"></text>
			</view>
		</view>
		<!-- 头部标题 end -->
		
		
		<!-- 没有加入课堂现实内容 -->
		<view class="" v-if="class_status">
			<view class="" style="display: flex;justify-content: center;margin-top:10vh;">
				<image  style="width: 300upx;height: 300upx;" src="../../../static/logo.png"></image>
			</view>
			
			<text style="display: flex;justify-content: center;margin-top: 2vh;font-weight: 600;">
				还没创建的课堂,赶快来创建一个吧
			</text>
			
			<text style="display: flex;justify-content: center;margin-top: 1vh;color: #888888;">
				进入班课后可以修改学生作业、发布活动...
			</text>
			
			<view class="padding flex flex-direction" >
				<button @click.native="toTClassDescPage()"  class="cu-btn bg-green margin-tb-sm lg">创建课堂</button>
			</view>
			
		</view>
		<!-- end -->
		
		<!-- 创建的课程 -->
		
		<view v-if="!class_status" class="" v-for="(item,index) in listData" :key="index">
		
		<view class="bg-white padding" style="display: flex;flex-wrap: wrap;"  @click.native="toClassDescPage(index)" >
			
			<view class="" style="display: flex;">
				<view class="">
					<image src="../../../static/logo.png" style="height: 150upx;width: 150upx;" mode=""></image>
				</view>
				
				<view class="" style="margin-left: 10upx;">
					
					<view class="" style="display: flex;align-items: center;">
						
						<view class="" style="width:65vw;height: 100upx;display: flex;flex-direction: column;margin-left: 10upx;">
							<text class="text-cut" style="font-weight: 600;">{{item.clazz}}</text>
							<view class="" style="margin-top: 20upx;">
								<text style="margin-top: 10upx;font-size: 25upx;">{{item.uname}}</text>
								<text class="text-cut "  style="margin-top: 10upx;font-size: 25upx;margin-left: 20upx; ">{{item.clazzName}}</text>
							</view>
						</view>
						
						<view class="" >
							<text class="lg text-gray cuIcon-right"></text>
						</view>
						
					</view>
					<view class="" style="display: flex;justify-content: space-between;width:72vw;padding: 5upx;margin-top: 10upx;">
						
						<view class="" style="display: flex;align-items: center;">
							<text class="lg text-gray cuIcon-appreciate"></text>
							<text style="font-size: 20upx;margin-left: 10upx;font-weight: 550;">签到</text>
						</view>
						
						
						<view class="" style="display: flex;align-items: center;margin-right: 10upx;">
							<text class="lg text-gray cuIcon-appreciate"></text>
							<text style="font-size: 20upx;margin-left: 10upx;font-weight: 550;">作业</text>
						</view>
						
						<view class="" style="display: flex;align-items: center;margin-right: 10upx;">
							<text class="lg text-gray cuIcon-appreciate"></text>
							<text style="font-size: 20upx;margin-left: 10upx;font-weight: 550;">抢答</text>
						</view>
					</view>
					
					
				</view>
				
			</view>
			
		</view>
		<view class="" style="height: 10upx ; width: 100%;"></view>
		</view>
		
		
		<!--加入的课程 end -->
		
		<!--  -->
		
	</view>
</template>

<script>
	var _this;
	export default {
		data() {
			return {
				listData:[],//列表数据
				title: 'Hello',
				class_status:false,//是否已有加入的课程
			}
		},
		onLoad() {
			_this= this;
			// 获取用户id
			var user_info = uni.getStorageSync("user_info");
			this.getHoemTeacherData(user_info.id);
		},
		onShow() {
		},
		methods: {
			
			// 首页数据读取
			getHoemTeacherData(uid){//得到教师创建的课堂数据
				uni.request({
					url:_this.api + "clazz/getTeacherClazz",//获取老师创建的课堂
					data:{
						uid:uid
					},
					header:{
						 "content-type":"application/x-www-form-urlencoded"
					},
					method:"POST",
					success: (res) => {
						console.log(res);
						_this.listData = res.data.data;
						// 判断是否有数据 状态显示
						if(_this.listData == null || _this.listData == [] ||_this.listData == ""){
							_this.class_status = true;
						}else{
							_this.class_status = false;
						}
						
					},
					fail: (err) => {
						uni.showToast({
							duration:2000,
							icon:"none",
							title:"数据加载失败！请稍后在试"
						})
					}
				})
			},
			
			
			//进入课堂详细
			toClassDescPage:function(index){
				var data = _this.listData[index];
				uni.navigateTo({
					url: '/pages/classDesc/classDesc_t/classDesc_t?id='+data.id + "&className=" + data.clazz +"&banji=" + data.clazzName,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
			
			//进入创建课堂详细
			toTClassDescPage:function(){
				uni.navigateTo({
					url: '/pages/index/index_t/index_t_classDesc',
				});
			}

		},
		beforeDestroy(){
			console.log("beforeDestroy")
			this.$eventHub.$off("scanResult");
		}
	}
</script>

<style>
	
	
</style>
